package com.ljz.config;


import com.ljz.common.token.TokenTemplate;
import feign.auth.BasicAuthRequestInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

@Configuration
public class FeignConfig  {

    @Value("${auth.key}")
    String key;

    @Value("${auth.secret}")
    String secret;

    @Autowired
    TokenTemplate tokenTemplate;

    @Bean
    public BasicAuthRequestInterceptor requestInterceptor() {

        Map map = new HashMap();

        map.put(key,secret);

        return new BasicAuthRequestInterceptor("key",tokenTemplate.getToken(map));

    }


}
